ESP32 LILYGO T-Relay Multiple Sliders


ESP32 LILYGO T-Relay Multiple Sliders

https://lilygo.cc/products/t-relay?_pos=1&_psq=Relay&_ss=e&_v=1.0&variant=42275965927605


Nederlandstalig

Bij het ontwikkelen van dit programma voor de ESP 32 is uitgegaan van de software en de toelichting van Rui en Sara Santos die zij hebben gegeven op https://RandomNerdTutorials.com/esp32-web-server-websocket-sliders. Sommige noodzakelijke instellingen worden door hun toegelicht in de beschrijving. Het is aan te bevelen eerst hun voorbeelden werkend te krijgen en daarna pas de uitgebreidere versie die hier gepresenteerd wordt te testen.

English language by Google Translate

This program for the ESP 32 was developed based on the software and the explanations of Rui and Sara Santos that they provided at https://RandomNerdTutorials.com/esp32-web-server-websocket-sliders. Some necessary settings are explained by them in the description. It is recommended to get their examples working first and then test the more extensive version presented here.


Hier kun je de bestanden downloaden



Korte beschrijving:

Als basis voor dit experiment is gebruik gemaakt van het bord ESP32 LILYGO T-Relay. Dit bord is uitgevoerd met een aansluiting voor 12 - 24 Volt uit een DC-regelaar, maakt hieruit 5 volt voor de 4 relais en 3,3 Volt voor de ESP32. Verder heeft het bord een aantal aansluitpennen om led's aan te sturen. De microcontroller is een gewone ESP32. De USB-aansluiting is type C, maar om de software te laden is een aparte unit nodig, de T-U2T.
https://lilygo.cc/products/t-u2t?_pos=1&_sid=3859bdffb&_ss=r

De relais hebben een wisselcontact en zijn geschikt om 10 A bij 230 V te schakelen. Ze zijn aangesloten via optische koppeling en hebben elk een rode led om de toestand aan te geven. Om de relais aan te sturen is het bereik van de sliders 1 t/m 4 beperkt van 0 tot 1, zodat er geen onduidelijke stand kan ontstaan.

Het bord heeft een rode led om te zien of het onder spanning staat. Deze led is aan te sturen met GPIO 25, geschakeld als Digitale Uitang, daarvoor is Fader 5 gebruikt. Omdat de gevoeligheid van het menselijk oog niet lineair is maar logaritmisch heeft deze fader 9 standen van 0 t/m 8. Inschakeltijd is in stappen van een factor 2 van 0 tot 255. Dus 0, 1, 3, 7, 15, 31, 63, 127, 255. De formule is ((2 tot de macht n)-1) met n van 0 tot 8. Verder is de frequentie in plaats van de standaard 5000 Hertz nu 7 Hertz waardoor een knippereffect kan ontstaan als de led niet volledig wordt aangestuurd.
Om de helderheid te tonen is een tweede slider aanwezig die eveneens reageert op fader 5. Omgekeerd reageert Fader 5 niet op deze tweede slider.

Short description:

The ESP32 LILYGO T-Relay board was used as a basis for this experiment. This board is equipped with a connection for 12 - 24 Volt from a DC regulator, which makes 5 volts for the 4 relays and 3.3 Volts for the ESP32. Furthermore, the board has a number of connection pins to control LEDs. The microcontroller is a regular ESP32. The USB connection is type C, but a separate unit is needed to load the software, the T-U2T.
https://lilygo.cc/products/t-u2t?_pos=1&_sid=3859bdffb&_ss=r

The relays have a changeover contact and are suitable for switching 10 A at 230 V. They are connected via optical coupling and each has a red LED to indicate the status. In order to control the relays, the range of sliders 1 to 4 is limited from 0 to 1, so that no unclear position can arise.


The board has a red LED to see if it is powered. This LED can be controlled with GPIO 25, connected as Digital Output, for which Fader 5 is used. Because the sensitivity of the human eye is not linear but logarithmic, this fader has 9 positions from 0 to 8. Switch-on time is in steps of a factor of 2 from 0 to 255. So 0, 1, 3, 7, 15, 31, 63, 127, 255. The formula is ((2 to the power n)-1) with n from 0 to 8. Furthermore, the frequency is now 7 Hertz instead of the standard 5000 Hertz, which can cause a flashing effect if the LED is not fully controlled.

To show the brightness, a second slider is present that also responds to fader 5. Conversely, Fader 5 does not respond to this second slider.


Een monitor, twee connecties met de sliders

Links IP=172.16.0.28 van de ESP32 als Station
Rechts IP=192.168.4.1 van de ESP32 als Access Point

Fader 6 stuurt de uitgang van GPIO 26, dat is een Digitaal naar Analoog Omzetter. Het bereik is in 255 stappen vanaf 0 tot ongeveer 3,0 Volt. Om de berekende spanning te tonen ook hier een tweede slider. De spanning wordt gemeten met Fader 8, aangesloten op Fader 8 = GPIO 34, een Analoog naar Digitaal omzetter in 4095 stappen. Ook hier een tweede slider om de berekende spanning aan te geven. Vanaf dit punt GPIO 26/GPIO34 leidt een weerstand van 330 Ohm naar de anode van een witte LED de kathode is verbonden aan 0 volt. De anode is ook verbonden met Fader 22 = GPIO 35, eveneens een ADC met een tweede slider voor de gemeten spanning. In het gegeven voorbeeld is de spanning over de weerstand 2780 - 2520 = 260 millivolt, dan is de stroom door de LED 260/330 = 787 milliampere.

On the left IP=172.16.0.28 of the ESP32 as Station
On the right IP=192.168.4.1 of the ESP32 as Access Point

Fader 6 controls the output of GPIO 26, which is a Digital to Analog Converter. The range is in 255 steps from 0 to approximately 3.0 Volts. To show the calculated voltage here also a second slider. The voltage is measured with Fader 8, connected to Fader 8 = GPIO 34, an Analog to Digital converter in 4095 steps. Here also a second slider to indicate the calculated voltage. From this point GPIO 26/GPIO34 leads a resistor of 330 Ohm to the anode of a white LED the cathode is connected to 0 volts. The anode is also connected to Fader 22 = GPIO 35, also an ADC with a second slider for the measured voltage. In the given example, the voltage across the resistor is 2780 - 2520 = 260 millivolts, then the current through the LED is 260/330 = 787 milliamperes.



Schema's

Rechts schema aansluiting witte LED aan DAC 26
Links schema aansluiting witte Power LED aan PWM 22

Fader 10 is aangesloten op een witte power LED, 12 Volt 3 Watt. Dan stroomt er door de LED maximaal 250 milliampere. De ESP32 kan maximaal 20 milliampere per uitgang leveren of afvoeren, met een maximum voor alle uitgangen tezamen van 40 milliampere. De witte power LED kan dus niet rechtstreeks aangestuurd worden, er is daarom een transistor BD139 tussengeschakeld volgens bovenstaand schema. De maximale stroom door de basis wordt begransd door de weerstand van 1 kiloohm tot ongeveer 2,5 milliampere. De stroomversterkingsfactor van de BD 139 is 150 of meer, daarmee zou de collectorstroom ruim 350 milliampere kunnen worden, maar die wordt begrensd door de power LED zelf. In de power LED zit een circuit wat er voor zorgt dat de power LED gebruikt kan worden met 12 Volt wisselstroom of 12 Volt gelijkstroom van willekeurige richting. Doordat de ESP32 Pulsbreedtemodulatie gebruikt wordt de BD 139 steeds volledig open of dicht aangestuurd zodat de transistor nauwelijks warm wordt en geen extra koeling nodig heeft.
Ook deze power LED is exponentieel aangstuurd waardoor er twee sliders nodig zijn om aan te geven welke trap is aangeklikt en hoe breed de puls is. Deze gaat in 17 trappen van 0 tot en met 16 en met de formule Wortel 2 tot de macht n minus 1, (((√2)^n)-1) met de waarden 0, 0, 1, 2, 3, 5, 7, 10, 15, 22, 31, 44, 63, 90, 127, 180 en 255.
LED dimmers op LED lampen met fase-aansnijding gaan bij lage standen meestal flikkeren, maar daar heeft deze constructie geen last van als de frequentie hoog is, bijvoorbeeld 5000 Hertz. Omdat in dit geval een lage frequentie is gebruikt, 5 Hertz, is het effect meer gelijk aan een zwaailicht.

Right diagram connection white LED to DAC 26
Left diagram connection white Power LED to PWM 22

Fader 10 is connected to a white power LED, 12 Volt 3 Watt. Then a maximum of 250 milliamperes flows through the LED. The ESP32 can supply or drain a maximum of 20 milliamperes per output, with a maximum of 40 milliamperes for all outputs together. The white power LED cannot be controlled directly, so a transistor BD139 is connected in between according to the diagram above. The maximum current through the base is limited by the resistance from 1 kiloohm to approximately 2.5 milliamperes. The current amplification factor of the BD 139 is 150 or more, which would allow the collector current to be more than 350 milliamperes, but this is limited by the power LED itself. The power LED contains a circuit that ensures that the power LED can be used with 12 Volt alternating current or 12 Volt direct current of any direction. Because the ESP32 uses Pulse Width Modulation, the BD 139 is always controlled fully open or closed, so that the transistor hardly gets warm and does not require additional cooling.

This power LED is also exponentially controlled, which means that two sliders are needed to indicate which step has been clicked and how wide the pulse is. This goes in 17 steps from 0 to 16 and with the formula Root of 2 to the power n minus 1, (((√2)^n)-1) with the values of 0, 0, 1, 2, 3, 5, 7, 10, 15, 22, 31, 44, 63, 90, 127, 180 and 255.
LED dimmers on LED lamps with phase control usually flicker at low settings, but this construction does not suffer from this if the frequency is high, for example 5000 Hertz. Because a low frequency has been used in this case, 5 Hertz, the effect is more similar to a flashing light.



Fader 12, 13 en 14 zijn elk via een weerstand van 330 ohm gekoppeld aan respectievelijk de rode, groene en blauwe led van een RGB Led met gemeenschappelijke anode. Om de gewenste kleur te krijgen moet wat geschoven worden met de sliders, groen is nogal overheersend voor het menselijk oog. Een kleur geel is te krijgen met 100% rood, ca 40% geel en 0% blauw.

Fader 15, 16 en 17 zijn witte led's, elk aangesloten via een weerstand van 330 ohm en de kathode aan 0 volt. Ze worden aangestuurd met frequentie 5, 7 en 9 Hertz waardoor ze knipperen als ze niet voluit worden aangestuurd.

Fader 18, 19 en 20 zijn net als de faders 13, 14 en 15 aan een RGB Led aangesloten, maar worden elk met een frequentie va 7 Hertz aangestuurd waardoor ze ook kunnen knipperen als ze niet voluit worden aangestuurd.

Faders 12, 13 and 14 are each connected via a 330 ohm resistor to the red, green and blue LED of an RGB LED with common anode. To get the desired colour, the sliders have to be moved a bit, green is rather dominant for the human eye. A colour yellow can be obtained with 100% red, approx. 40% yellow and 0% blue.


Faders 15, 16 and 17 are white LEDs, each connected via a 330 ohm resistor and the cathode to 0 volts. They are controlled with frequencies of 5, 7 and 9 Hertz, which makes them flash when they are not fully controlled.


Faders 18, 19 and 20 are connected to an RGB LED, just like faders 13, 14 and 15, but are each controlled with a frequency of 7 Hertz, which makes them flash when they are not fully controlled.



Video